package com.authine.cloudpivot.ext.utils.system;

import com.authine.cloudpivot.ext.constants.AppConst;
import com.authine.cloudpivot.ext.constants.ServiceUrlConst;
import com.authine.cloudpivot.ext.enums.system.OrganizationAttributeEnum;
import com.authine.cloudpivot.ext.utils.HttpClients;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @ClassName OrgAttributeUtils
 * @Description: 组织属性工具类，方便调用
 * @Author fj
 * @Date 2021/8/20
 * @Version V1.0
 **/
public class OrgAttributeUtils {
    /**
     * 判断对应组织属性是否开启
     *
     * @param orgId         组织id
     * @param attributeEnum 组织属性
     * @return true：启用状态   false：禁用状态
     */
    public static boolean isEnabledAttribute(String orgId, OrganizationAttributeEnum attributeEnum) {
        String url = HttpClients.getUrl(AppConst.SYSTEM_MANAGEMENT, ServiceUrlConst.IS_ENABLED_ATTRIBUTE_URL);
        Map<String, Object> orgAttributeMap = Maps.newHashMap();
        orgAttributeMap.put("organization_id", orgId);
        orgAttributeMap.put("attribute", attributeEnum.name());
        return HttpClients.execute(url, orgAttributeMap, Boolean.class);
    }
}
